<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>商品列表</title>
<link rel="stylesheet"
	href="${ pageContext.request.contextPath }/css/goodslist.css" />
<script type="text/javascript"
	src="${ pageContext.request.contextPath }/js/goodslist.js"></script>
<link href="${pageContext.request.contextPath}/css/Style1.css"
	rel="stylesheet" type="text/css" />
<!-- 引入Jquery -->
<script type="text/javascript"
	src="${ pageContext.request.contextPath }/static/js/jquery-2.1.1.min.js"></script>
<!-- 引入样式 -->
<link
	href="${ pageContext.request.contextPath }/static/bootstrap-3.3.7-dist/css/bootstrap.min.css"
	rel="stylesheet">
<script
	src="'${ pageContext.request.contextPath }/static/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>

<script type="text/javascript">
function addProduct(){
	window.location.href = "${pageContext.request.contextPath}/admin/adminProduct_addPage.action";
}
function edit(pid) {
			window.location.href = "${pageContext.request.contextPath}/admin/adminProduct_edit.action?pid="+pid;
}
function deletecs(pid) {
	var r=confirm("确定删除吗？");
	if (r==true){
		window.location.href = "${pageContext.request.contextPath}/admin/adminProduct_deletecs.action?pid="+pid;
	}
	else{
	}
}
function look(pid) {
	window.location.href = "${pageContext.request.contextPath}/admin/adminProduct_look.action?pid="+pid;
}
function xiajia(pid) {
	var r=confirm("确定要下架该商品吗？");
	if (r==true){
		window.location.href = "${pageContext.request.contextPath}/admin/adminProduct_xiajia.action?pid="+pid;
	}
	else{
	}
}

function shangjia(pid) {
	var r=confirm("确定要上架该商品吗？");
	if (r==true){
		window.location.href = "${pageContext.request.contextPath}/admin/adminProduct_xiajia.action?pid="+pid;
	}
	else{
	}
}

function ret() {
	window.location.href = "${pageContext.request.contextPath}/admin/adminProduct_findAllByPage.action?page=1";
}
function refresh(){
	window.location.href = "${pageContext.request.contextPath}/admin/adminProduct_findAllByPage.action?page=1";
}
</script>

</head>
<body>
	<div class="a">
		<div class="b">
			<form method="post"
				action="${pageContext.request.contextPath}/adminsearchProduct.action">
				<input id="condition" name="condition" type="text" class="input1"
					value="请输入关键词" onfocus="this.value = '';"
					onblur="if (this.value == '') {this.value = '请输入关键词';}">&nbsp;&nbsp;
				<button type="submit"
					class="btn btn-primary btn-sm glyphicon glyphicon-search"
					onclick="validate()"></button>
			</form>
		</div>

		<div style="float: left; padding-left: 20px;">
			<form
				action="${pageContext.request.contextPath}/admin/findproByCs.action?csid=${c.csid}">
				<!-- 商品种类： -->
				<select name="csid" id="csid"
					style="height: 32px; width: 120px; border-radius: 4px;">
					<c:forEach var="c" items="${categoryList}">
						<option value="${c.csid }">${c.csname}</option>
					</c:forEach>
				</select> &nbsp;
				<button type="submit"
					class="btn btn-primary btn-sm glyphicon glyphicon-search"></button>
			</form>
		</div>

		<div align="right" style="padding-right: 30px;">
			<input type="button" value="+添加商品" class="btn btn-primary"
				onclick="addProduct()" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<button type="button" onclick="refresh()"
				class="btn glyphicon glyphicon-refresh"></button>
		</div>
	</div>

	<div class="d" style="width: 96%; margin-left: 25px;">
		<!-- 显示结果 -->
		<form style="margin-top: 20px;">
			<table width="100%" align="center"
				class="table table-hover table-striped" id="table"
				style="border: 1px solid #D0D0D0">
				<thead>
					<tr align="center" bgcolor="#93b6bd" height="33px;">
						<th scope="col" style="text-align: center;">商品ID</th>
						<th scope="col" style="text-align: center;">商品图片</th>
						<th scope="col" style="text-align: center;">商品名称</th>
						<th scope="col" style="text-align: center;">商品价格</th>
						<th scope="col" style="text-align: center;">是否热门</th>
						<th scope="col" style="text-align: center;">状态</th>
						<th scope="col" style="text-align: center;">操作</th>
					</tr>
				</thead>
				<!-- <tbody></tbody> -->
				<c:forEach items="${srList}" var="p" varStatus="status">
					<tr height="30">
						<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="12%">${p.pid}</td>
						<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="16%"><img
							width="40" height="45"
							src="${ pageContext.request.contextPath }/${p.image}"></td>
						<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="17%">${p.pname }</td>
						<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="17%">${p.shopPrice}</td>
						<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="8%"><c:choose>
								<c:when test="${p.isHot==1 }">
														是
										</c:when>
								<c:otherwise>
														否
										</c:otherwise>
							</c:choose></td>

						<td style="CURSOR: hand; HEIGHT: 22px" align="center" width=" "><c:choose>
								<c:when test="${p.state==0}">
														上架中  
									<button type="button"
										class="btn btn-warning btn-sm glyphicon glyphicon-arrow-down"
										onclick="xiajia(${p.pid})"></button>
								</c:when>
								<c:otherwise>
									<h9 style="color: red;">已下架</h9>
									<button type="button"
										class="btn btn-warning btn-sm glyphicon glyphicon-arrow-up"
										onclick="shangjia(${p.pid})"></button>
								</c:otherwise>
							</c:choose></td>
						<td>
							<button type="button"
								class="btn btn-primary btn-sm glyphicon glyphicon-pencil"
								onclick="edit(${p.pid})"></button>&nbsp;
							<button type="button"
								class="btn btn-success btn-sm glyphicon glyphicon-asterisk"
								onclick="look(${p.pid})"></button>
						</td>
					</tr>
				</c:forEach>
			</table>
		</form>
	</div>


</body>
</html>

